package com.soc.erp.index;

import java.util.List;

import org.nature.framework.annotation.Ask;
import org.nature.framework.annotation.Ctrl;
import org.nature.framework.annotation.Inject;
import org.nature.framework.annotation.Redirect;
import org.nature.framework.bean.JsonData;
import org.nature.framework.core.NatureCtrl;
import org.nature.framework.core.NatureMap;

import com.alibaba.fastjson.JSONObject;

@Ctrl(namespace = "/statistics")
public class StatisticsCtrl extends NatureCtrl {
	@Inject
	IService iService;
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
 
	
	//企业申请查看档案
		@Ask
		@Redirect
		public Object check(){
			
			JSONObject json = new JSONObject();
			String string = "[";   //退役数
			String years = "[";    //年份
			String sql = "SELECT count(id) countNum, substr(join_army_date,1,4) year FROM tb_veteran_info GROUP BY substr(join_army_date,1,4) ORDER BY  join_army_date DESC"; 
			
			List<NatureMap> scount = iService.list(sql);
			//System.out.println(scount);
		
			for(int i=0;i<scount.size();i++)
			{
				string =string+scount.get(i).getString("countnum")+",";
				years =years+scount.get(i).getString("year")+",";
			}
			string = string.substring(0, string.length()-1);//去掉最后一个逗号
			string = string+"]";
			
			years = years.substring(0, years.length()-1);//去掉最后一个逗号
			years = years+"]";
			
			json.put("num1",string);
			json.put("num2",years);
			
			System.out.println(json);
			//json.put("code", 2);
			//Response.Write("{\"rows1\":[10,20,30,40,50,200,70,100,90,200,100,60]}");
			//System.out.println("check");
			//String str =  "[23,33, 7, 88, 22,24, 36, 55, 67, 77, 45, 55]";
			//String str =  "[23,33]";
			//json.put("rows1", "23,70");
		 
			//json.put("num1", "[23,33,7,88,22,24,36,55,67,77,45,55]");
			//json.put("num2", "[10,20,30,40,50,120,65,80,90,140,130,70]");
		   //System.out.println(new JsonData(scount));
			 
			return new JsonData(json);
			
			//return new JsonData("\"rows1\":[10,20,30,40,50,200,70,100,90,200,100,60]");
 
		}
}
